home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 November / Freeware November 1998.img / dist / fw_emacs.idb / usr / freeware / info / emacs-19.z / emacs-19 (.txt)
GNU Info File  |  1998-10-27  |  50KB  |  878 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.63 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Sorting,  Next: Narrowing,  Prev: Postscript,  Up: Top
  4. Sorting Text
  5. ============
  6.    Emacs provides several commands for sorting text in the buffer.  All
  7. operate on the contents of the region (the text between point and the
  8. mark).  They divide the text of the region into many "sort records",
  9. identify a "sort key" for each record, and then reorder the records
  10. into the order determined by the sort keys.  The records are ordered so
  11. that their keys are in alphabetical order, or, for numeric sorting, in
  12. numeric order.  In alphabetic sorting, all upper case letters `A'
  13. through `Z' come before lower case `a', in accord with the ASCII
  14. character sequence.
  15.    The various sort commands differ in how they divide the text into
  16. sort records and in which part of each record is used as the sort key.
  17. Most of the commands make each line a separate sort record, but some
  18. commands use paragraphs or pages as sort records.  Most of the sort
  19. commands use each entire sort record as its own sort key, but some use
  20. only a portion of the record as the sort key.
  21. `M-x sort-lines'
  22.      Divide the region into lines, and sort by comparing the entire
  23.      text of a line.  A numeric argument means sort into descending
  24.      order.
  25. `M-x sort-paragraphs'
  26.      Divide the region into paragraphs, and sort by comparing the entire
  27.      text of a paragraph (except for leading blank lines).  A numeric
  28.      argument means sort into descending order.
  29. `M-x sort-pages'
  30.      Divide the region into pages, and sort by comparing the entire
  31.      text of a page (except for leading blank lines).  A numeric
  32.      argument means sort into descending order.
  33. `M-x sort-fields'
  34.      Divide the region into lines, and sort by comparing the contents of
  35.      one field in each line.  Fields are defined as separated by
  36.      whitespace, so the first run of consecutive non-whitespace
  37.      characters in a line constitutes field 1, the second such run
  38.      constitutes field 2, etc.
  39.      Specify which field to sort by with a numeric argument: 1 to sort
  40.      by field 1, etc.  A negative argument means count fields from the
  41.      right instead of from the left; thus, minus 1 means sort by the
  42.      last field.  If several lines have identical contents in the field
  43.      being sorted, they keep same relative order that they had in the
  44.      original buffer.
  45.      A negative argument means count fields from the right (from the
  46.      end of the line).
  47. `M-x sort-numeric-fields'
  48.      Like `M-x sort-fields' except the specified field is converted to
  49.      an integer for each line, and the numbers are compared.  `10'
  50.      comes before `2' when considered as text, but after it when
  51.      considered as a number.
  52. `M-x sort-columns'
  53.      Like `M-x sort-fields' except that the text within each line used
  54.      for comparison comes from a fixed range of columns.  See below for
  55.      an explanation.
  56. `M-x reverse-region'
  57.      Reverse the order of the lines in the region.  This is useful for
  58.      sorting into descending order by fields or columns, since those
  59.      sort commands do not have a feature for doing that.
  60.    For example, if the buffer contains this:
  61.      On systems where clash detection (locking of files being edited) is
  62.      implemented, Emacs also checks the first time you modify a buffer
  63.      whether the file has changed on disk since it was last visited or
  64.      saved.  If it has, you are asked to confirm that you want to change
  65.      the buffer.
  66. applying `M-x sort-lines' to the entire buffer produces this:
  67.      On systems where clash detection (locking of files being edited) is
  68.      implemented, Emacs also checks the first time you modify a buffer
  69.      saved.  If it has, you are asked to confirm that you want to change
  70.      the buffer.
  71.      whether the file has changed on disk since it was last visited or
  72. where the upper case `O' sorts before all lower case letters.  If you
  73. use `C-u 2 M-x sort-fields' instead, you get this:
  74.      implemented, Emacs also checks the first time you modify a buffer
  75.      saved.  If it has, you are asked to confirm that you want to change
  76.      the buffer.
  77.      On systems where clash detection (locking of files being edited) is
  78.      whether the file has changed on disk since it was last visited or
  79. where the sort keys were `Emacs', `If', `buffer', `systems' and `the'.
  80.    `M-x sort-columns' requires more explanation.  You specify the
  81. columns by putting point at one of the columns and the mark at the other
  82. column.  Because this means you cannot put point or the mark at the
  83. beginning of the first line to sort, this command uses an unusual
  84. definition of `region': all of the line point is in is considered part
  85. of the region, and so is all of the line the mark is in, as well as all
  86. the lines in between.
  87.    For example, to sort a table by information found in columns 10 to
  88. 15, you could put the mark on column 10 in the first line of the table,
  89. and point on column 15 in the last line of the table, and then run
  90. `sort-columns'.  Equivalently, you could run it with the mark on column
  91. 15 in the first line and point on column 10 in the last line.
  92.    This can be thought of as sorting the rectangle specified by point
  93. and the mark, except that the text on each line to the left or right of
  94. the rectangle moves along with the text inside the rectangle.  *Note
  95. Rectangles::.
  96.    Many of the sort commands ignore case differences when comparing, if
  97. `sort-fold-case' is non-`nil'.
  98. File: emacs,  Node: Narrowing,  Next: Two-Column,  Prev: Sorting,  Up: Top
  99. Narrowing
  100. =========
  101.    "Narrowing" means focusing in on some portion of the buffer, making
  102. the rest temporarily inaccessible.  The portion which you can still get
  103. to is called the "accessible portion".  Canceling the narrowing, which
  104. makes the entire buffer once again accessible, is called "widening".
  105. The amount of narrowing in effect in a buffer at any time is called the
  106. buffer's "restriction".
  107.    Narrowing can make it easier to concentrate on a single subroutine or
  108. paragraph by eliminating clutter.  It can also be used to restrict the
  109. range of operation of a replace command or repeating keyboard macro.
  110. `C-x n n'
  111.      Narrow down to between point and mark (`narrow-to-region').
  112. `C-x n w'
  113.      Widen to make the entire buffer accessible again (`widen').
  114. `C-x n p'
  115.      Narrow down to the current page (`narrow-to-page').
  116.    When you have narrowed down to a part of the buffer, that part
  117. appears to be all there is.  You can't see the rest, you can't move
  118. into it (motion commands won't go outside the accessible part), you
  119. can't change it in any way.  However, it is not gone, and if you save
  120. the file all the inaccessible text will be saved.  The word `Narrow'
  121. appears in the mode line whenever narrowing is in effect.
  122.    The primary narrowing command is `C-x n n' (`narrow-to-region').  It
  123. sets the current buffer's restrictions so that the text in the current
  124. region remains accessible but all text before the region or after the
  125. region is inaccessible.  Point and mark do not change.
  126.    Alternatively, use `C-x n p' (`narrow-to-page') to narrow down to
  127. the current page.  *Note Pages::, for the definition of a page.
  128.    The way to cancel narrowing is to widen with `C-x n w' (`widen').
  129. This makes all text in the buffer accessible again.
  130.    You can get information on what part of the buffer you are narrowed
  131. down to using the `C-x =' command.  *Note Position Info::.
  132.    Because narrowing can easily confuse users who do not understand it,
  133. `narrow-to-region' is normally a disabled command.  Attempting to use
  134. this command asks for confirmation and gives you the option of enabling
  135. it; if you enable the command, confirmation will no longer be required
  136. for it.  *Note Disabling::.
  137. File: emacs,  Node: Two-Column,  Next: Editing Binary Files,  Prev: Narrowing,  Up: Top
  138. Two-Column Editing
  139. ==================
  140.    Two-column mode lets you conveniently edit two side-by-side columns
  141. of text.  It uses two side-by-side windows, each showing its own buffer.
  142.    There are three ways to enter two-column mode:
  143. `f2 2' or `C-x 6 2'
  144.      Enter two-column mode with the current buffer on the left, and on
  145.      the right, a buffer whose name is based on the current buffer's
  146.      name (`2C-two-columns').  If the right-hand buffer doesn't already
  147.      exist, it starts out empty; the current buffer's contents are not
  148.      changed.
  149.      This command is appropriate when the current buffer is empty or
  150.      contains just one column and you want to add another column.
  151. `f2 s' or `C-x 6 s'
  152.      Split the current buffer, which contains two-column text, into two
  153.      buffers, and display them side by side (`2C-split').  The current
  154.      buffer becomes the left-hand buffer, but the text in the right-hand
  155.      column is moved into the right-hand buffer.  The current column
  156.      specifies the split point.  Splitting starts with the current line
  157.      and continues to the end of the buffer.
  158.      This command is appropriate when you have a buffer that already
  159.      contains two-column text, and you wish to separate the columns
  160.      temporarily.
  161. `f2 b BUFFER RET'
  162. `C-x 6 b BUFFER RET'
  163.      Enter two-column mode using the current buffer as the left-hand
  164.      buffer, and using buffer BUFFER as the right-hand buffer
  165.      (`2C-associate-buffer').
  166.    `f2 s' or `C-x 6 s' looks for a column separator which is a string
  167. that appears on each line between the two columns.  You can specify the
  168. width of the separator with a numeric argument to `f2 s'; that many
  169. characters, before point, constitute the separator string.  By default,
  170. the width is 1, so the column separator is the character before point.
  171.    When a line has the separator at the proper place, `f2 s' puts the
  172. text after the separator into the right-hand buffer, and deletes the
  173. separator.  Lines that don't have the column separator at the proper
  174. place remain unsplit; they stay in the left-hand buffer, and the
  175. right-hand buffer gets an empty line to correspond.  (This is the way to
  176. write a line which "spans both columns while in two-column mode": write
  177. it in the left-hand buffer, and put an empty line in the right-hand
  178. buffer.)
  179.    The command `C-x 6 RET' or `f2 RET' (`2C-newline') inserts a newline
  180. in each of the two buffers at corresponding positions.  This is the
  181. easiest way to add a new line to the two-column text while editing it
  182. in split buffers.
  183.    When you have edited both buffers as you wish, merge them with `f2
  184. 1' or `C-x 6 1' (`2C-merge').  This copies the text from the right-hand
  185. buffer as a second column in the other buffer.  To go back to
  186. two-column editing, use `f2 s'.
  187.    Use `f2 d' or `C-x 6 d' to disassociate the two buffers, leaving
  188. each as it stands (`2C-dissociate').  If the other buffer, the one not
  189. current when you type `f2 d', is empty, `f2 d' kills it.
  190. File: emacs,  Node: Editing Binary Files,  Next: Saving Emacs Sessions,  Prev: Two-Column,  Up: Top
  191. Editing Binary Files
  192. ====================
  193.    There is a special major mode for editing binary files: Hexl mode.
  194. To use it, use `M-x hexl-find-file' instead of `C-x C-f' to visit the
  195. file.  This command converts the file's contents to hexadecimal and
  196. lets you edit the translation.  When you save the file, it is converted
  197. automatically back to binary.
  198.    You can also use `M-x hexl-mode' to translate an existing buffer
  199. into hex.  This is useful if you visit a file normally and then discover
  200. it is a binary file.
  201.    Ordinary text characters overwrite in Hexl mode.  This is to reduce
  202. the risk of accidentally spoiling the alignment of data in the file.
  203. There are special commands for insertion.  Here is a list of the
  204. commands of Hexl mode:
  205. `C-M-d'
  206.      Insert a byte with a code typed in decimal.
  207. `C-M-o'
  208.      Insert a byte with a code typed in octal.
  209. `C-M-x'
  210.      Insert a byte with a code typed in hex.
  211. `C-x ['
  212.      Move to the beginning of a 1k-byte "page".
  213. `C-x ]'
  214.      Move to the end of a 1k-byte "page".
  215. `M-g'
  216.      Move to an address specified in hex.
  217. `M-j'
  218.      Move to an address specified in decimal.
  219. `C-c C-c'
  220.      Leave Hexl mode, going back to the major mode this buffer had
  221.      before you invoked `hexl-mode'.
  222. File: emacs,  Node: Saving Emacs Sessions,  Next: Recursive Edit,  Prev: Editing Binary Files,  Up: Top
  223. Saving Emacs Sessions
  224. =====================
  225.    You can use the Desktop library to save the state of Emacs from one
  226. session to another.  Saving the state means that Emacs starts up with
  227. the same set of buffers, major modes, buffer positions, and so on that
  228. the previous Emacs session had.
  229.    To use Desktop, you should first add these lines at the end of your
  230. `.emacs' file:
  231.      (load "desktop")
  232.      (desktop-load-default)
  233.      (desktop-read)
  234. The first time you save the state of the Emacs session, you must do it
  235. manually, with the command `M-x desktop-save'.  Once you have done
  236. that, exiting Emacs will save the state again--not only the present
  237. Emacs session, but also subsequent sessions.  You can also save the
  238. state at any time, without exiting Emacs, by typing `M-x desktop-save'
  239. again.
  240.    In order for Emacs to recover the state from a previous session, you
  241. must start it with the same current directory as you used when you
  242. started the previous session.
  243.    The variable `desktop-files-not-to-save' controls which files are
  244. excluded from state saving.  Its value is a regular expression that
  245. matches the files to exclude.  By default, remote (ftp-accessed) files
  246. are excluded; this is because visiting them again in the subsequent
  247. session would be slow.  If you want to include these files in state
  248. saving, set `desktop-files-not-to-save' to `"^$"'.
  249. File: emacs,  Node: Recursive Edit,  Next: Emulation,  Prev: Saving Emacs Sessions,  Up: Top
  250. Recursive Editing Levels
  251. ========================
  252.    A "recursive edit" is a situation in which you are using Emacs
  253. commands to perform arbitrary editing while in the middle of another
  254. Emacs command.  For example, when you type `C-r' inside of a
  255. `query-replace', you enter a recursive edit in which you can change the
  256. current buffer.  On exiting from the recursive edit, you go back to the
  257. `query-replace'.
  258.    "Exiting" the recursive edit means returning to the unfinished
  259. command, which continues execution.  The command to exit is `C-M-c'
  260. (`exit-recursive-edit').
  261.    You can also "abort" the recursive edit.  This is like exiting, but
  262. also quits the unfinished command immediately.  Use the command `C-]'
  263. (`abort-recursive-edit') to do this.  *Note Quitting::.
  264.    The mode line shows you when you are in a recursive edit by
  265. displaying square brackets around the parentheses that always surround
  266. the major and minor mode names.  Every window's mode line shows this,
  267. in the same way, since being in a recursive edit is true of Emacs as a
  268. whole rather than any particular window or buffer.
  269.    It is possible to be in recursive edits within recursive edits.  For
  270. example, after typing `C-r' in a `query-replace', you may type a
  271. command that enters the debugger.  This begins a recursive editing level
  272. for the debugger, within the recursive editing level for `C-r'.  Mode
  273. lines display a pair of square brackets for each recursive editing
  274. level currently in progress.
  275.    Exiting the inner recursive edit (such as, with the debugger `c'
  276. command) resumes the command running in the next level up.  When that
  277. command finishes, you can then use `C-M-c' to exit another recursive
  278. editing level, and so on.  Exiting applies to the innermost level only.
  279. Aborting also gets out of only one level of recursive edit; it returns
  280. immediately to the command level of the previous recursive edit.  If you
  281. wish, you can then abort the next recursive editing level.
  282.    Alternatively, the command `M-x top-level' aborts all levels of
  283. recursive edits, returning immediately to the top level command reader.
  284.    The text being edited inside the recursive edit need not be the same
  285. text that you were editing at top level.  It depends on what the
  286. recursive edit is for.  If the command that invokes the recursive edit
  287. selects a different buffer first, that is the buffer you will edit
  288. recursively.  In any case, you can switch buffers within the recursive
  289. edit in the normal manner (as long as the buffer-switching keys have
  290. not been rebound).  You could probably do all the rest of your editing
  291. inside the recursive edit, visiting files and all.  But this could have
  292. surprising effects (such as stack overflow) from time to time.  So
  293. remember to exit or abort the recursive edit when you no longer need it.
  294.    In general, we try to minimize the use of recursive editing levels in
  295. GNU Emacs.  This is because they constrain you to "go back" in a
  296. particular order-from the innermost level toward the top level.  When
  297. possible, we present different activities in separate buffers so that
  298. you can switch between them as you please.  Some commands switch to a
  299. new major mode which provides a command to switch back.  These
  300. approaches give you more flexibility to go back to unfinished tasks in
  301. the order you choose.
  302. File: emacs,  Node: Emulation,  Next: Dissociated Press,  Prev: Recursive Edit,  Up: Top
  303. Emulation
  304. =========
  305.    GNU Emacs can be programmed to emulate (more or less) most other
  306. editors.  Standard facilities can emulate these:
  307. EDT (DEC VMS editor)
  308.      Turn on EDT emulation with `M-x edt-emulation-on'.  `M-x
  309.      edt-emulation-off' restores normal Emacs command bindings.
  310.      Most of the EDT emulation commands are keypad keys, and most
  311.      standard Emacs key bindings are still available.  The EDT
  312.      emulation rebindings are done in the global keymap, so there is no
  313.      problem switching buffers or major modes while in EDT emulation.
  314. vi (Berkeley editor)
  315.      Viper is the newest emulator for vi.  It implements several levels
  316.      of emulation; level 1 is closest to vi itself, while level 5
  317.      departs somewhat from strict emulation to take advantage of the
  318.      capabilities of Emacs.  To invoke Viper, type `M-x viper-mode'; it
  319.      will guide you the rest of the way and ask for the emulation level.
  320. vi (another emulator)
  321.      `M-x vi-mode' enters a major mode that replaces the previously
  322.      established major mode.  All of the vi commands that, in real vi,
  323.      enter "input" mode are programmed instead to return to the
  324.      previous major mode.  Thus, ordinary Emacs serves as vi's "input"
  325.      mode.
  326.      Because vi emulation works through major modes, it does not work
  327.      to switch buffers during emulation.  Return to normal Emacs first.
  328.      If you plan to use vi emulation much, you probably want to bind a
  329.      key to the `vi-mode' command.
  330. vi (alternate emulator)
  331.      `M-x vip-mode' invokes another vi emulator, said to resemble real
  332.      vi more thoroughly than `M-x vi-mode'.  "Input" mode in this
  333.      emulator is changed from ordinary Emacs so you can use ESC to go
  334.      back to emulated vi command mode.  To get from emulated vi command
  335.      mode back to ordinary Emacs, type `C-z'.
  336.      This emulation does not work through major modes, and it is
  337.      possible to switch buffers in various ways within the emulator.
  338.      It is not so necessary to assign a key to the command `vip-mode' as
  339.      it is with `vi-mode' because terminating insert mode does not use
  340.      it.
  341.      For full information, see the long comment at the beginning of the
  342.      source file, which is `lisp/vip.el' in the Emacs distribution.
  343. File: emacs,  Node: Dissociated Press,  Next: Amusements,  Prev: Emulation,  Up: Top
  344. Dissociated Press
  345. =================
  346.    `M-x dissociated-press' is a command for scrambling a file of text
  347. either word by word or character by character.  Starting from a buffer
  348. of straight English, it produces extremely amusing output.  The input
  349. comes from the current Emacs buffer.  Dissociated Press writes its
  350. output in a buffer named `*Dissociation*', and redisplays that buffer
  351. after every couple of lines (approximately) so you can read the output
  352. as it comes out.
  353.    Dissociated Press asks every so often whether to continue generating
  354. output.  Answer `n' to stop it.  You can also stop at any time by
  355. typing `C-g'.  The dissociation output remains in the `*Dissociation*'
  356. buffer for you to copy elsewhere if you wish.
  357.    Dissociated Press operates by jumping at random from one point in the
  358. buffer to another.  In order to produce plausible output rather than
  359. gibberish, it insists on a certain amount of overlap between the end of
  360. one run of consecutive words or characters and the start of the next.
  361. That is, if it has just printed out `president' and then decides to jump
  362. to a different point in the file, it might spot the `ent' in `pentagon'
  363. and continue from there, producing `presidentagon'.(1)  Long sample
  364. texts produce the best results.
  365.    A positive argument to `M-x dissociated-press' tells it to operate
  366. character by character, and specifies the number of overlap characters.
  367. A negative argument tells it to operate word by word and specifies the
  368. number of overlap words.  In this mode, whole words are treated as the
  369. elements to be permuted, rather than characters.  No argument is
  370. equivalent to an argument of two.  For your againformation, the output
  371. goes only into the buffer `*Dissociation*'.  The buffer you start with
  372. is not changed.
  373.    Dissociated Press produces nearly the same results as a Markov chain
  374. based on a frequency table constructed from the sample text.  It is,
  375. however, an independent, ignoriginal invention.  Dissociated Press
  376. techniquitously copies several consecutive characters from the sample
  377. between random choices, whereas a Markov chain would choose randomly for
  378. each word or character.  This makes for more plausible sounding results,
  379. and runs faster.
  380.    It is a mustatement that too much use of Dissociated Press can be a
  381. developediment to your real work.  Sometimes to the point of outragedy.
  382. And keep dissociwords out of your documentation, if you want it to be
  383. well userenced and properbose.  Have fun.  Your buggestions are welcome.
  384.    ---------- Footnotes ----------
  385.    (1)  This dissociword actually appeared during the Vietnam War, when
  386. it was very appropriate.
  387. File: emacs,  Node: Amusements,  Next: Customization,  Prev: Dissociated Press,  Up: Top
  388. Other Amusements
  389. ================
  390.    If you are a little bit bored, you can try `M-x hanoi'.  If you are
  391. considerably bored, give it a numeric argument.  If you are very very
  392. bored, try an argument of 9.  Sit back and watch.
  393.    If you want a little more personal involvement, try `M-x gomoku',
  394. which plays the game Go Moku with you.
  395.    `M-x blackbox' and `M-x mpuz' are two kinds of puzzles.  `blackbox'
  396. challenges you to determine the location of objects inside a box by
  397. tomography.  `mpuz' displays a multiplication puzzle with letters
  398. standing for digits in a code that you must guess--to guess a value,
  399. type a letter and then the digit you think it stands for.
  400.    `M-x dunnet' runs an adventure-style exploration game, which is a
  401. bigger sort of puzzle.
  402.    When you are frustrated, try the famous Eliza program.  Just do `M-x
  403. doctor'.  End each input by typing `RET' twice.
  404.    When you are feeling strange, type `M-x yow'.
  405. File: emacs,  Node: Customization,  Next: Quitting,  Prev: Amusements,  Up: Top
  406. Customization
  407. *************
  408.    This chapter talks about various topics relevant to adapting the
  409. behavior of Emacs in minor ways.  See `The Emacs Lisp Reference Manual'
  410. for how to make more far-reaching changes.
  411.    All kinds of customization affect only the particular Emacs session
  412. that you do them in.  They are completely lost when you kill the Emacs
  413. session, and have no effect on other Emacs sessions you may run at the
  414. same time or later.  The only way an Emacs session can affect anything
  415. outside of it is by writing a file; in particular, the only way to make
  416. a customization `permanent' is to put something in your `.emacs' file
  417. or other appropriate file to do the customization in each session.
  418. *Note Init File::.
  419. * Menu:
  420. * Minor Modes::           Each minor mode is one feature you can turn on
  421.                  independently of any others.
  422. * Variables::           Many Emacs commands examine Emacs variables
  423.                  to decide what to do; by setting variables,
  424.                  you can control their functioning.
  425. * Keyboard Macros::       A keyboard macro records a sequence of
  426.                  keystrokes to be replayed with a single
  427.                  command.
  428. * Key Bindings::       The keymaps say what command each key runs.
  429.                  By changing them, you can "redefine keys".
  430. * Keyboard Translations::  If your keyboard passes an undesired code
  431.                  for a key, you can tell Emacs to
  432.                  substitute another code.
  433. * Syntax::           The syntax table controls how words and
  434.                   expressions are parsed.
  435. * Init File::           How to write common customizations in the
  436.                              `.emacs' file.
  437. File: emacs,  Node: Minor Modes,  Next: Variables,  Up: Customization
  438. Minor Modes
  439. ===========
  440.    Minor modes are optional features which you can turn on or off.  For
  441. example, Auto Fill mode is a minor mode in which SPC breaks lines
  442. between words as you type.  All the minor modes are independent of each
  443. other and of the selected major mode.  Most minor modes say in the mode
  444. line when they are on; for example, `Fill' in the mode line means that
  445. Auto Fill mode is on.
  446.    Append `-mode' to the name of a minor mode to get the name of a
  447. command function that turns the mode on or off.  Thus, the command to
  448. enable or disable Auto Fill mode is called `M-x auto-fill-mode'.  These
  449. commands are usually invoked with `M-x', but you can bind keys to them
  450. if you wish.  With no argument, the function turns the mode on if it was
  451. off and off if it was on.  This is known as "toggling".  A positive
  452. argument always turns the mode on, and an explicit zero argument or a
  453. negative argument always turns it off.
  454.    Enabling or disabling some minor modes applies only to the current
  455. buffer; each buffer is independent of the other buffers.  Therefore, you
  456. can enable the mode in particular buffers and disable it in others.  The
  457. per-buffer minor modes include Auto Fill mode, Auto Save mode, Font-Lock
  458. mode, ISO Accents mode, Outline minor mode, Overwrite mode, and Binary
  459. Overwrite mode.
  460.    Auto Fill mode allows you to enter filled text without breaking lines
  461. explicitly.  Emacs inserts newlines as necessary to prevent lines from
  462. becoming too long.  *Note Filling::.
  463.    Auto Save mode causes the contents of a buffer to be saved
  464. periodically to reduce the amount of work you can lose in case of a
  465. system crash.  *Note Auto Save::.
  466.    Enriched mode enables editing and saving of formatted text.  *Note
  467. Formatted Text::.
  468.    Font-Lock mode automatically highlights certain textual units found
  469. in programs, such as comments, strings, and function names being
  470. defined.  This requires a window system that can display multiple fonts.
  471. *Note Faces::.
  472.    ISO Accents mode makes the characters ``', `'', `"', `^', `/' and
  473. `~' combine with the following letter, to produce an accented letter in
  474. the ISO Latin-1 character set.  *Note European Display::.
  475.    Outline minor mode provides the same facilities as the major mode
  476. called Outline mode; but since it is a minor mode instead, you can
  477. combine it with any major mode.  *Note Outline Mode::.
  478.    Overwrite mode causes ordinary printing characters to replace
  479. existing text instead of shoving it to the right.  For example, if
  480. point is in front of the `B' in `FOOBAR', then in Overwrite mode typing
  481. a `G' changes it to `FOOGAR', instead of producing it `FOOGBAR' as
  482. usual.  Binary Overwrite mode is a variant of Overwrite mode for
  483. editing binary files; it treats newlines and tabs like other
  484. characters, so that they overwrite other characters and can be
  485. overwritten by them.
  486.    The following minor modes normally apply to all buffers at once.
  487. Since each is enabled or disabled by the value of a variable, you *can*
  488. set them differently for particular buffers, by explicitly making the
  489. corresponding variables local in those buffers.  *Note Locals::.
  490.    Abbrev mode allows you to define abbreviations that automatically
  491. expand as you type them.  For example, `amd' might expand to `abbrev
  492. mode'.  *Note Abbrevs::, for full information.
  493.    Icomplete mode displays an indication of available completions when
  494. you are in the minibuffer and completion is active.  *Note Completion
  495. Options::.
  496.    Line Number mode enables continuous display in the mode line of the
  497. line number of point.  *Note Mode Line::.
  498.    Resize-Minibuffer mode makes the minibuffer expand as necessary to
  499. hold the text that you put in it.  *Note Minibuffer Edit::.
  500.    Scroll Bar mode gives each window a scroll bar (*note Scroll
  501. Bars::.).  Menu Bar mode gives each frame a menu bar (*note Menu
  502. Bars::.).  Both of these modes are enabled by default when you use the
  503. X Window System.
  504.    In Transient Mark mode, every change in the buffer contents
  505. "deactivates" the mark, so that commands that operate on the region
  506. will get an error.  This means you must either set the mark, or
  507. explicitly "reactivate" it, before each command that uses the region.
  508. The advantage of Transient Mark mode is that Emacs can display the
  509. region highlighted (currently only when using X).  *Note Setting Mark::.
  510.    For most minor modes, the command name is also the name of a variable
  511. which directly controls the mode.  The mode is enabled whenever this
  512. variable's value is non-`nil', and the minor mode command works by
  513. setting the variable.  For example, the command `outline-minor-mode'
  514. works by setting the value of `outline-minor-mode' as a variable; it is
  515. this variable that directly turns Outline minor mode on and off.  To
  516. check whether a given minor mode works this way, use `C-h v' to ask for
  517. documentation on the variable name.
  518.    These minor mode variables provide a good way for Lisp programs to
  519. turn minor modes on and off; they are also useful in a file's local
  520. variables list.  But please think twice before setting minor modes with
  521. a local variables list, because most minor modes are matter of user
  522. preference--other users editing the same file might not want the same
  523. minor modes you prefer.
  524. File: emacs,  Node: Variables,  Next: Keyboard Macros,  Prev: Minor Modes,  Up: Customization
  525. Variables
  526. =========
  527.    A "variable" is a Lisp symbol which has a value.  The symbol's name
  528. is also called the name of the variable.  A variable name can contain
  529. any characters that can appear in a file, but conventionally variable
  530. names consist of words separated by hyphens.  A variable can have a
  531. documentation string which describes what kind of value it should have
  532. and how the value will be used.
  533.    Lisp allows any variable to have any kind of value, but most
  534. variables that Emacs uses require a value of a certain type.  Often the
  535. value should always be a string, or should always be a number.
  536. Sometimes we say that a certain feature is turned on if a variable is
  537. "non-`nil'," meaning that if the variable's value is `nil', the feature
  538. is off, but the feature is on for *any* other value.  The conventional
  539. value to use to turn on the feature--since you have to pick one
  540. particular value when you set the variable--is `t'.
  541.    Emacs uses many Lisp variables for internal record keeping, as any
  542. Lisp program must, but the most interesting variables for you are the
  543. ones that exist for the sake of customization.  Emacs does not (usually)
  544. change the values of these variables; instead, you set the values, and
  545. thereby alter and control the behavior of certain Emacs commands.  These
  546. variables are called "user options".  Most user options are documented
  547. in this manual, and appear in the Variable Index (*note Variable
  548. Index::.).
  549.    One example of a variable which is a user option is `fill-column',
  550. which specifies the position of the right margin (as a number of
  551. characters from the left margin) to be used by the fill commands (*note
  552. Filling::.).
  553. * Menu:
  554. * Examining::         Examining or setting one variable's value.
  555. * Edit Options::     Examining or editing list of all user options' values.
  556. * Hooks::         Hook variables let you specify programs for parts
  557.                of Emacs to run on particular occasions.
  558. * Locals::         Per-buffer values of variables.
  559. * File Variables::   How files can specify variable values.
  560. File: emacs,  Node: Examining,  Next: Edit Options,  Up: Variables
  561. Examining and Setting Variables
  562. -------------------------------
  563. `C-h v VAR RET'
  564.      Display the value and documentation of variable VAR
  565.      (`describe-variable').
  566. `M-x set-variable RET VAR RET VALUE RET'
  567.      Change the value of variable VAR to VALUE.
  568.    To examine the value of a single variable, use `C-h v'
  569. (`describe-variable'), which reads a variable name using the
  570. minibuffer, with completion.  It displays both the value and the
  571. documentation of the variable.  For example,
  572.      C-h v fill-column RET
  573. displays something like this:
  574.      fill-column's value is 75
  575.      
  576.      Documentation:
  577.      *Column beyond which automatic line-wrapping should happen.
  578.      Automatically becomes buffer-local when set in any fashion.
  579. The star at the beginning of the documentation indicates that this
  580. variable is a user option.  `C-h v' is not restricted to user options;
  581. it allows any variable name.
  582.    The most convenient way to set a specific user option is with `M-x
  583. set-variable'.  This reads the variable name with the minibuffer (with
  584. completion), and then reads a Lisp expression for the new value using
  585. the minibuffer a second time.  For example,
  586.      M-x set-variable RET fill-column RET 75 RET
  587. sets `fill-column' to 75.
  588.    `M-x set-variable' is limited to user option variables.  You can set
  589. any variable with a Lisp expression using the function `setq'.  Here's
  590. how to use it to set `fill-column':
  591.      (setq fill-column 75)
  592.    Setting variables, like all means of customizing Emacs except where
  593. otherwise stated, affects only the current Emacs session.
  594. File: emacs,  Node: Edit Options,  Next: Hooks,  Prev: Examining,  Up: Variables
  595. Editing Variable Values
  596. -----------------------
  597.    These two functions make it easy to display all the Emacs user option
  598. variables, and to change some of them if you wish.
  599. `M-x list-options'
  600.      Display a buffer listing names, values and documentation of all
  601.      options.
  602. `M-x edit-options'
  603.      Change user option values by editing a list of user option
  604.      variables.
  605.    `M-x list-options' displays a list of all Emacs option variables, in
  606. an Emacs buffer named `*List Options*'.  Each user option is shown with
  607. its documentation and its current value.  Here is what a portion of it
  608. might look like:
  609.      ;; exec-path:
  610.      ("." "/usr/local/bin" "/usr/ucb" "/bin" "/usr/bin" "/u2/emacs/etc")
  611.      *List of directories to search programs to run in subprocesses.
  612.      Each element is a string (directory name)
  613.      or nil (try the default directory).
  614.      ;;
  615.      ;; fill-column:
  616.      75
  617.      *Column beyond which automatic line-wrapping should happen.
  618.      Automatically becomes buffer-local when set in any fashion.
  619.      ;;
  620.    `M-x edit-options' goes one step further and immediately selects the
  621. `*List Options*' buffer; this buffer uses the major mode Options mode,
  622. which provides commands that allow you to point at a user option
  623. variable and change its value:
  624.      Set the variable point is in or near to a new value read using the
  625.      minibuffer.
  626.      Toggle the variable point is in or near: if the value was `nil',
  627.      it becomes `t'; otherwise it becomes `nil'.
  628.      Set the variable point is in or near to `t'.
  629.      Set the variable point is in or near to `nil'.
  630.      Move to the next or previous user option.
  631.    Any changes take effect immediately, and last until you exit from
  632. Emacs.
  633. File: emacs,  Node: Hooks,  Next: Locals,  Prev: Edit Options,  Up: Variables
  634. Hooks
  635. -----
  636.    A "hook" is a variable where you can store a function or functions
  637. to be called on a particular occasion by an existing program.  Emacs
  638. provides a number of hooks for the sake of customization.
  639.    Most of the hooks in Emacs are "normal hooks".  These variables
  640. contain lists of functions to be called with no arguments.  The reason
  641. most hooks are normal hooks is so that you can use them in a uniform
  642. way.  Every variable in Emacs whose name ends in `-hook' is a normal
  643. hook.
  644.    Most major modes run hooks as the last step of initialization.  This
  645. makes it easy for a user to customize the behavior of the mode, by
  646. overriding the local variable assignments already made by the mode.  But
  647. hooks may also be used in other contexts.  For example, the hook
  648. `suspend-hook' runs just before Emacs suspends itself (*note
  649. Exiting::.).
  650.    The recommended way to add a hook function to a normal hook is by
  651. calling `add-hook'.  You can use any valid Lisp function as the hook
  652. function.  For example, here's how to set up a hook to turn on Auto
  653. Fill mode when entering Text mode and other modes based on Text mode:
  654.      (add-hook 'text-mode-hook 'turn-on-auto-fill)
  655.    The next example shows how to use a hook to customize the indentation
  656. of C code.  (People often have strong personal preferences for one
  657. format compared to another.)  Here the hook function is an anonymous
  658. lambda expression.
  659.      (setq my-c-style
  660.        '((c-comment-only-line-offset . 4)
  661.          (c-cleanup-list . (scope-operator
  662.                     empty-defun-braces
  663.                     defun-close-semi))
  664.          (c-offsets-alist . ((arglist-close . c-lineup-arglist)
  665.                  (substatement-open . 0)))))
  666.      
  667.      (add-hook 'c-mode-common-hook
  668.        (function (lambda ()
  669.          (c-add-style "my-style" my-c-style t))))
  670.    It is best to design your hook functions so that the order in which
  671. they are executed does not matter.  Any dependence on the order is
  672. "asking for trouble."  However, the order is predictable: the most
  673. recently added hook functions are executed first.
  674. File: emacs,  Node: Locals,  Next: File Variables,  Prev: Hooks,  Up: Variables
  675. Local Variables
  676. ---------------
  677. `M-x make-local-variable RET VAR RET'
  678.      Make variable VAR have a local value in the current buffer.
  679. `M-x kill-local-variable RET VAR RET'
  680.      Make variable VAR use its global value in the current buffer.
  681. `M-x make-variable-buffer-local RET VAR RET'
  682.      Mark variable VAR so that setting it will make it local to the
  683.      buffer that is current at that time.
  684.    Almost any variable can be made "local" to a specific Emacs buffer.
  685. This means that its value in that buffer is independent of its value in
  686. other buffers.  A few variables are always local in every buffer.
  687. Every other Emacs variable has a "global" value which is in effect in
  688. all buffers that have not made the variable local.
  689.    `M-x make-local-variable' reads the name of a variable and makes it
  690. local to the current buffer.  Further changes in this buffer will not
  691. affect others, and further changes in the global value will not affect
  692. this buffer.
  693.    `M-x make-variable-buffer-local' reads the name of a variable and
  694. changes the future behavior of the variable so that it will become local
  695. automatically when it is set.  More precisely, once a variable has been
  696. marked in this way, the usual ways of setting the variable automatically
  697. do `make-local-variable' first.  We call such variables "per-buffer"
  698. variables.
  699.    Major modes (*note Major Modes::.) always make variables local to the
  700. buffer before setting the variables.  This is why changing major modes
  701. in one buffer has no effect on other buffers.  Minor modes also work by
  702. setting variables--normally, each minor mode has one controlling
  703. variable which is non-`nil' when the mode is enabled (*note Minor
  704. Modes::.).  For most minor modes, the controlling variable is per
  705. buffer.
  706.    Emacs contains a number of variables that are always per-buffer.
  707. These include `abbrev-mode', `auto-fill-function', `case-fold-search',
  708. `comment-column', `ctl-arrow', `fill-column', `fill-prefix',
  709. `indent-tabs-mode', `left-margin', `mode-line-format', `overwrite-mode',
  710. `selective-display-ellipses', `selective-display', `tab-width', and
  711. `truncate-lines'.  Some other variables are always local in every
  712. buffer, but they are used for internal purposes.
  713.    A few variables cannot be local to a buffer because they are always
  714. local to each display instead (*Note Multiple Displays::).  If you try
  715. to make one of these variables buffer-local, you'll get an error
  716. message.
  717.    `M-x kill-local-variable' reads the name of a variable and makes it
  718. cease to be local to the current buffer.  The global value of the
  719. variable henceforth is in effect in this buffer.  Setting the major mode
  720. kills all the local variables of the buffer except for a few variables
  721. specially marked as "permanent locals".
  722.    To set the global value of a variable, regardless of whether the
  723. variable has a local value in the current buffer, you can use the Lisp
  724. construct `setq-default'.  This construct is used just like `setq', but
  725. it sets variables' global values instead of their local values (if
  726. any).  When the current buffer does have a local value, the new global
  727. value may not be visible until you switch to another buffer.  Here is
  728. an example:
  729.      (setq-default fill-column 75)
  730. `setq-default' is the only way to set the global value of a variable
  731. that has been marked with `make-variable-buffer-local'.
  732.    Lisp programs can use `default-value' to look at a variable's
  733. default value.  This function takes a symbol as argument and returns its
  734. default value.  The argument is evaluated; usually you must quote it
  735. explicitly.  For example, here's how to obtain the default value of
  736. `fill-column':
  737.      (default-value 'fill-column)
  738. File: emacs,  Node: File Variables,  Prev: Locals,  Up: Variables
  739. Local Variables in Files
  740. ------------------------
  741.    A file can specify local variable values for use when you edit the
  742. file with Emacs.  Visiting the file checks for local variables
  743. specifications; it automatically makes these variables local to the
  744. buffer, and sets them to the values specified in the file.
  745.    There are two ways to specify local variable values: in the first
  746. line, or with a local variables list.  Here's how to specify them in the
  747. first line:
  748.      -*- mode: MODENAME; VAR: VALUE; ... -*-
  749. You can specify any number of variables/value pairs in this way, each
  750. pair with a colon and semicolon as shown above.  `mode: MODENAME;'
  751. specifies the major mode; this should come first in the line.  The
  752. VALUEs are not evaluated; they are used literally.  Here is an example
  753. that specifies Lisp mode and sets two variables with numeric values:
  754.      ;; -*-mode: Lisp; fill-column: 75; comment-column: 50; -*-
  755.    A "local variables list" goes near the end of the file, in the last
  756. page.  (It is often best to put it on a page by itself.)  The local
  757. variables list starts with a line containing the string `Local
  758. Variables:', and ends with a line containing the string `End:'.  In
  759. between come the variable names and values, one set per line, as
  760. `VARIABLE: VALUE'.  The VALUEs are not evaluated; they are used
  761. literally.  If a file has both a local variables list and a `-*-' line,
  762. Emacs processes *everything* in the `-*-' line first, and *everything*
  763. in the local variables list afterward.
  764.    Here is an example of a local variables list:
  765.      ;;; Local Variables: ***
  766.      ;;; mode:lisp ***
  767.      ;;; comment-column:0 ***
  768.      ;;; comment-start: ";;; "  ***
  769.      ;;; comment-end:"***" ***
  770.      ;;; End: ***
  771.    As you see, each line starts with the prefix `;;; ' and each line
  772. ends with the suffix ` ***'.  Emacs recognizes these as the prefix and
  773. suffix based on the first line of the list, by finding them surrounding
  774. the magic string `Local Variables:'; then it automatically discards
  775. them from the other lines of the list.
  776.    The usual reason for using a prefix and/or suffix is to embed the
  777. local variables list in a comment, so it won't confuse other programs
  778. that the file is intended as input for.  The example above is for a
  779. language where comment lines start with `;;; ' and end with `***'; the
  780. local values for `comment-start' and `comment-end' customize the rest
  781. of Emacs for this unusual syntax.  Don't use a prefix (or a suffix) if
  782. you don't need one.
  783.    Two "variable names" have special meanings in a local variables
  784. list: a value for the variable `mode' really sets the major mode, and a
  785. value for the variable `eval' is simply evaluated as an expression and
  786. the value is ignored.  `mode' and `eval' are not real variables;
  787. setting variables named `mode' and `eval' in any other context has no
  788. special meaning.  If `mode' is used to set a major mode, it should be
  789. the first "variable" in the list.
  790.    You can use the `mode' "variable" to set minor modes as well as
  791. major modes; in fact, you can use it more than once, first to set the
  792. major mode and then to set minor modes which are specific to particular
  793. buffers.  But most minor modes should not be specified in the file in
  794. any fashion, because they represent user preferences.  For example, you
  795. should not try to specify Auto Fill mode with file local variables,
  796. because whether to use Auto Fill mode for editing a particular kind of
  797. text is a matter of personal taste, not an aspect of the format of the
  798. text.
  799.    The start of the local variables list must be no more than 3000
  800. characters from the end of the file, and must be in the last page if the
  801. file is divided into pages.  Otherwise, Emacs will not notice it is
  802. there.  The purpose of this rule is so that a stray `Local Variables:'
  803. not in the last page does not confuse Emacs, and so that visiting a
  804. long file that is all one page and has no local variables list need not
  805. take the time to search the whole file.
  806.    You may be tempted to try to turn on Auto Fill mode with a local
  807. variable list.  That is a mistake.  The choice of Auto Fill mode or not
  808. is a matter of individual taste, not a matter of the contents of
  809. particular files.  If you want to use Auto Fill, set up major mode
  810. hooks with your `.emacs' file to turn it on (when appropriate) for you
  811. alone (*note Init File::.).  Don't try to use a local variable list
  812. that would impose your taste on everyone.
  813.    The variable `enable-local-variables' controls whether to process
  814. local variables lists, and thus gives you a chance to override them.
  815. Its default value is `t', which means do process local variables lists.
  816. If you set the value to `nil', Emacs simply ignores local variables
  817. lists.  Any other value says to query you about each local variables
  818. list, showing you the local variables list to consider.
  819.    The `eval' "variable", and certain actual variables, create a
  820. special risk; when you visit someone else's file, local variable
  821. specifications for these could affect your Emacs in arbitrary ways.
  822. Therefore, the option `enable-local-eval' controls whether Emacs
  823. processes `eval' variables, as well variables with names that end in
  824. `-hook', `-hooks', `-function' or `-functions', and certain other
  825. variables.  The three possibilities for the option's value are `t',
  826. `nil', and anything else, just as for `enable-local-variables'.  The
  827. default is `maybe', which is neither `t' nor `nil', so normally Emacs
  828. does ask for confirmation about file settings for these variables.
  829.    Use the command `normal-mode' to reset the local variables and major
  830. mode of a buffer according to the file name and contents, including the
  831. local variables list if any.  *Note Choosing Modes::.
  832. File: emacs,  Node: Keyboard Macros,  Next: Key Bindings,  Prev: Variables,  Up: Customization
  833. Keyboard Macros
  834. ===============
  835.    A "keyboard macro" is a command defined by the user to stand for
  836. another sequence of keys.  For example, if you discover that you are
  837. about to type `C-n C-d' forty times, you can speed your work by
  838. defining a keyboard macro to do `C-n C-d' and calling it with a repeat
  839. count of forty.
  840. `C-x ('
  841.      Start defining a keyboard macro (`start-kbd-macro').
  842. `C-x )'
  843.      End the definition of a keyboard macro (`end-kbd-macro').
  844. `C-x e'
  845.      Execute the most recent keyboard macro (`call-last-kbd-macro').
  846. `C-u C-x ('
  847.      Re-execute last keyboard macro, then add more keys to its
  848.      definition.
  849. `C-x q'
  850.      When this point is reached during macro execution, ask for
  851.      confirmation (`kbd-macro-query').
  852. `M-x name-last-kbd-macro'
  853.      Give a command name (for the duration of the session) to the most
  854.      recently defined keyboard macro.
  855. `M-x insert-kbd-macro'
  856.      Insert in the buffer a keyboard macro's definition, as Lisp code.
  857. `C-x C-k'
  858.      Edit a previously defined keyboard macro (`edit-kbd-macro').
  859. `M-x apply-macro-to-region-lines'
  860.      Run the last keyboard macro on each complete line in the region.
  861.    Keyboard macros differ from ordinary Emacs commands in that they are
  862. written in the Emacs command language rather than in Lisp.  This makes
  863. it easier for the novice to write them, and makes them more convenient
  864. as temporary hacks.  However, the Emacs command language is not powerful
  865. enough as a programming language to be useful for writing anything
  866. intelligent or general.  For such things, Lisp must be used.
  867.    You define a keyboard macro while executing the commands which are
  868. the definition.  Put differently, as you define a keyboard macro, the
  869. definition is being executed for the first time.  This way, you can see
  870. what the effects of your commands are, so that you don't have to figure
  871. them out in your head.  When you are finished, the keyboard macro is
  872. defined and also has been, in effect, executed once.  You can then do
  873. the whole thing over again by invoking the macro.
  874. * Menu:
  875. * Basic Kbd Macro::  Defining and running keyboard macros.
  876. * Save Kbd Macro::   Giving keyboard macros names; saving them in files.
  877. * Kbd Macro Query::  Keyboard macros that do different things each use.
  878.